<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String basepath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ request.getContextPath() + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<style type="text/css">
.qh_right{
	border-bottom:1px solid #ccc;
}
.qh_right>p{
	line-height:40px;
}

.qh_right>p>span{
	display:inline-block;
	width:150px;
	font-size:15px;
}
.qh_right>p>.qh_span1,.qh_right>p>.qh_span3{
	width:250px;
}
.qh_right>p>.qh_bg{
	width:40px;
	float:right;
	cursor: pointer;
}
.adm_sh{
	display:none;
}
.adm_sh>div{
	float:left;
	width: 40%;
	height: 110px;
	padding: 10px;
	background-color: #fff;
	margin-left:15px;
	
}
.adm_sh>div>textarea{
	width: 280px;
	height:90px;
	margin: 0 auto;
}
.adm_sh>input{
	width:60px;
	height: 20px;
	border-radius: 5px;
	background-color: #90c624;
	color: #fff;
	border:1px solid #ccc;
	margin:20px 20px;
	cursor:pointer;
}
.adm_sh>div>p{
	line-height: 16px;
	font-size:14px;
	border-bottom:1px solid #ccc;
}
.adm_sh>div>p>span{
	display:inline-block;
	width:80px;
	font-weight:700;
	}
.fenlei{
	margin-bottom:15px;              
}
.fenlei>ul{
	float:left;
	border: 1px solid #c3c3c5;
	padding-left:0px;
}
.fenlei>ul>b{
	float:left;
}
.fenlei>ul>li{
	cursor: pointer;
	padding:3px 10px;
	float: left;
	list-style: none;
}
.fenlei>ul .leixing{
	background: #c3c3c5;
	border:1px solid #c3c3c5;
	margin-right: 10px;
	font-size: 12px;
}
#each_div{
	height:400px;
	overflow-y:scroll;
}
.bg_change{
	background-color:#90c624;
}
</style>
<div class="body_top">
	<div>
		<p>审批项目</p>
		<div>
			<p>VENUE FOR EXAMINATION ADD APPROVAL OF</p>
			<p class="last_p">NEVER SO KIND</p>
		</div>
	</div>
</div>
<div class="fenlei clearfix">
	<ul id="pass_data">
		<b>审核状态：</b>
		<li class="leixing" title="0">未审核</li>
		<li class="leixing" title="1">审核通过</li>
		<li class="leixing" title="2">审核不通过</li>
	</ul>
</div>
<div class="aaa">
	<div id="each_div">
	<c:forEach items="${requestScope.prolist }" var="list">
	<div class="qh_right"  title="${list.get(0).p_status}">
			
				<p>
					<span class="qh_span1"><b>主题：</b>[${list.get(0).p_name }]</span>
					<span ><b>类型：</b>[${list.get(2).pt_name }]</span>
					<span class="qh_span3"><b>所属团队：</b>${list.get(1).te_name }</span>
					<span class="qh_bg"><img src="img/ss.png"></span>
				</p>
				<div class="adm_sh clearfix" title="${list.get(0).p_id }" >
				<div>
				<p>
					<span>项目ID：</span>${list.get(0).p_id }
				</p><p>
					<span>团队ID：</span>${list.get(1).te_id }
				</p>
				<p>
					<span>申请时间：</span>${list.get(0).p_ctime }
				</p>
				<p>
					<span>所属团队：</span>${list.get(1).te_name }
				<p>
					<span>状态：</span>
					<c:choose>
						<c:when test="${list.get(0).p_status == 0}">未审核</c:when>
						<c:when test="${list.get(0).p_status == 1}">审核通过</c:when>
						<c:otherwise>审核不通过</c:otherwise>
					</c:choose>
				</p>
				
				</div>
				<div>
					<textarea placeholder="请输入审核意见" <c:if test="${list.get(0).p_status !=0 }">disabled=ture</c:if>><c:if test="${list.get(0).p_status !=0 }">${list.get(0).p_remarks != null ? list.get(0).p_remarks : '无意见'  }</c:if></textarea>
				</div>
				<c:if test="${list.get(0).p_status ==0 }">
					<input type="button" value="同意发布" name="1">
					<input type="button" value="不同意" name="2">
				</c:if>
			</div>
	</div>
	</c:forEach>
	</div>
<div class="fy" title="${sum != null?sum:1 }">
	<span id="pre_page">上一页</span>
		<ul>
		</ul>
	<span id="next_page">下一页</span>
</div>
</div>
<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	//项目展开
	$("#each_div").delegate('span.qh_bg','click',function(){
		$(this).parent().next().slideToggle();
	})
	
	//---------------------------
	var kind="pros";
	var status=undefined;
	/* var sum =$("div.fy").attr("title");  */
	var sum =20;
	var connect_page=0;
	printList(1);
	//类型选择
	$("li.leixing").click(function(){
		$(this).css({"background":"#b2d771","color":"#fff"});
        $(this).siblings('li').css({"background":"#c3c3c5","color":"#000"});
		status=$(this).attr("title");
		 $("div.fy>ul>li").eq(0).trigger("click");
	})
	//项目审核

	$("#each_div").delegate('input','click',function(){
		var that=$(this);
		var opnion=that.parent().children('div').eq(1).children().val()
		var obj_sh={
			pid:that.parent().attr('title'),
			id:that.attr("name"),
			opin:opnion
		}
		console.log(obj_sh);
		getData('admin/examPro',push_item,obj_sh);
	})
	
	function push_item(data){
		if(data){
			alert("操作成功")
			window.location.reload()
		}
	}
		// 分页及动态写数据	  admin/fenye?html=teac&&type=?&&page=?
		   function printList(index){
		     var fy_html="";
		     var show = sum-index>7?8:sum-index+1;
		     if(index<=connect_page){
		         for(var i=8;i>0;i--){
		             fy_html+="<li>"+(index-i+1)+"</li>";
		         }
		         $(".fy>ul").html(fy_html);
		         $(".fy>ul>li").eq(7).addClass('fy_on');
		     }else{
		         for(var i=0;i<show;i++){
		             fy_html+="<li>"+(index+i)+"</li>";
		         }
		         $(".fy>ul").html(fy_html);
		         $(".fy>ul>li").eq(0).addClass('fy_on');
		     }
		     connect_page=index;
		 }
			    //点击分页  分别触发ajax事件以及分页列表事件
			    $(".fy>ul").delegate('li','click',function(){
			        type=$("#bg_black").attr("title");
			        $(this).addClass('fy_on');
			        $(this).siblings("li").attr("class","");
			        var page = $(this).html();
			        if(sum>8&&(page%7==1)&&page>7){
			            printList(Number(page));
			            }else{
			                connect_page=page;
			            }
			            connect_data(kind,page,status);
			        })
			        
			     // 上一页  and 下一页
			$("#pre_page").click(function(){
		     var pre_page=(connect_page-1)%7;
		     pre_page= pre_page==0?7:pre_page;
		     $("div.fy>ul>li").eq(pre_page-1).trigger("click");
		 });
		 
		  $("#next_page").click(function(){
		     var next_page=(Number(connect_page)+1)%7;
		      next_page= next_page==0?7:next_page ;
		      next_page= next_page==1?8:next_page ;
		     $("div.fy>ul>li").eq(next_page-1).trigger("click");
		 }) 
		 
			//拼接ajax地址
		 function connect_data(kind,page,status){
		     status= (status == undefined?"":"&&status="+status);
		     var address ="admin/fenye?html="+kind+status+"&&page="+page;
		     getData(address,printData)
		     console.log(address)
		 }
 // ajax传值取相应数据
 function getData(address,callback,Data,that){

     $.ajax({
         type:"post",
         url:address,
         data:Data,
         dataType:"json",
         success:function(data){
         	 console.log(data);
             callback(data);
         },
         error:function(e){
             console.log(e.message);
         }
     });
 }

 function printData(data){
		var pros_html="";
		
		$.each(data.paging,function(){
			var that=this.list;
			if(!that[0].p_status){
pros_html+= "<div class=\"qh_right\">"+
"				<p>"+
"					<span class=\"qh_span1\"><b>主题：</b>"+that[0].p_name+"</span>"+
"					<span ><b>类型：</b>"+that[2].pt_name+"</span>"+
"					<span class=\"qh_span3\"><b>所属团队：</b>"+that[1].te_name+"</span>"+
"					<span class=\"qh_bg\"><img src=\"img/ss.png\"></span>"+
"				</p>"+
"				<div class=\"adm_sh clearfix\" title="+that[0].p_id+">"+
"					<div>"+
"						<p>"+
" 							<span>项目ID：</span>"+that[0].p_id+
"						</p>"+
"						<p>"+
"							<span>团队ID：</span>"+that[1].te_id+
"						</p>"+
"						<p>"+
"							<span>申请时间：</span>"+that[0].p_ctime+
"						<p>"+
"							<span>所属团队：</span>"+that[1].te_name+
"						</p>"+
"						<p>"+
"							<span>状态：</span>未审核"+
"						</p>"+
"					</div>"+
"				<div>"+
"					<textarea placeholder=\"请输入审核意见\" >审核意见：</textarea>"+
"				</div>"+
"				<input type=\"button\" value=\"同意发布\" name=\"1\">"+
"					<input type=\"button\" value=\"不同意\" name=\"2\">"+
"			</div>"+
"	</div>";
		}else{
			var status =that[0].p_status==1?"审核通过":"审核不通过";
			pros_html+= "<div class=\"qh_right\">"+
			"				<p>"+
			"					<span class=\"qh_span1\"><b>主题：</b>"+that[0].p_name+"</span>"+
			"					<span ><b>类型：</b>"+that[2].pt_name+"</span>"+
			"					<span class=\"qh_span3\"><b>所属团队：</b>"+that[1].te_name+"</span>"+
			"					<span class=\"qh_bg\"><img src=\"img/ss.png\"></span>"+
			"				</p>"+
			"				<div class=\"adm_sh clearfix\" title="+that[0].p_id+">"+
			"					<div>"+
			"						<p>"+
			" 							<span>项目ID：</span>"+that[0].p_id+
			"						</p>"+
			"						<p>"+
			"							<span>团队ID：</span>"+that[1].te_id+
			"						</p>"+
			"						<p>"+
			"							<span>申请时间：</span>"+that[0].p_ctime+
			"						<p>"+
			"							<span>所属团队：</span>"+that[1].te_name+
			"						</p>"+
			"						<p>"+
			"							<span>状态：</span>"+status+
			"						</p>"+
			"					</div>"+
			"				<div>"+
			"					<textarea placeholder=\"请输入审核意见\" disabled=true>审核意见："+that[0].p_remarks+"</textarea>"+
			"				</div>"+
			"			</div>"+
			"	</div>";
		}
		});
		
		$("#each_div").html(pros_html);
	}
});
</script>
	
